define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'car/carinfo/index',
                    add_url: 'car/carinfo/add',
                    edit_url: 'car/carinfo/edit',
                    del_url: 'car/carinfo/del',
                    multi_url: 'car/carinfo/multi',
                    table: 'car_carinfo',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate: false},
                        {field: 'car_name', title: __('Car_name')},
                        {field: 'car_type', title: __('Car_type')},
                        {field: 'passenger_num', title: __('Passenger_num')},
                        {field: 'status', title: __('Status'),formatter: Table.api.formatter.status, searchList: {1: __('Normal'), 0: __('Hidden')}},

                        {field: 'car_number', title: __('Car_number'),operate: false},
                        {field: 'dri_number', title: __('Dri_number'),operate: false},
                        {field: 'images', title: __('Images'), formatter: Table.api.formatter.images,operate: false},

                        {field: 'manufacturer', title: __('Manufacturer'),operate: false},
                        {field: 'buy_time', title: __('Buy_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,operate: false},

                        {field: 'validity_time', title: __('Validity_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'maintenance', title: __('Maintenance'),operate: false},
                        {field: 'description', title: __('Description'),operate: false},

                        {field: 'frist_dir', title: __('Frist_dir'),operate: false},
                        {field: 'second_dir', title: __('Second_dir'),operate: false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});